package com.yingside.collection.game;


import java.util.ArrayList;
import java.util.List;

public class Hero {
	private String name;
	private int hp;
	private int attack;
	private int defence;
	private int ownMoney;

	private List<Weapon> weaponBag;
	private List<Armor> armorBag;
	private List<Shoes> shoesBag;
	private List<Shield> shieldBag;

	private Equipment equipment;

	public Hero(){
		this("哪吒",100,20,8,20000);
	}
	public Hero(String name){
		this(name,100,10,3,3000);
	}
	public Hero(String name, int hp, int attack, int defence,int ownMoney
	) {
		this.name = name;
		this.hp = hp;
		this.attack = attack;
		this.defence = defence;
		this.ownMoney = ownMoney;
		this.weaponBag = new ArrayList<Weapon>();
		this.armorBag = new ArrayList<Armor>();
		this.shoesBag = new ArrayList<Shoes>();
		this.shieldBag = new ArrayList<Shield>();
		equipment = new Equipment();

	}

	public void dressEquipment(Weapon w){
		//判断英雄的身上有没有武器
		//如果身上的equipment!=null就是装备了武器
		if(this.equipment.getWeapon() != null){
			//1.先将身上的武器放入到背包中
			this.weaponBag.add(this.equipment.getWeapon());
			//2.将之前加上去的属性移除掉
			this.attack -= this.equipment.getWeapon().getAttack();
			//3.再将武器从身上卸掉
			this.equipment.setWeapon(null);
		}

		//身上装备新武器,同时背包中的武器应该移除
		this.equipment.setWeapon(w);
		this.weaponBag.remove(w);

		//英雄加上新的属性
		this.attack += w.getAttack();



	}

	public void dressEquipment(Armor w){

	}
	//鞋子,盾牌的重载


	public void fight(Enemy m){
		System.out.println(this.name + "提着长枪,冲向了-->" + m.getName());
		m.injured(this);
	}

	public int injured(Enemy m){
		int lostLife = GameUtil.getLostLife(m.getAttack(), this.defence);

		this.hp -= lostLife;

		if(this.hp <= 0){
			System.out.println("英雄你已经挂掉了...请重新开始!");
			return 0;
		}

		System.out.println("======英雄受伤======");
		System.out.println("吸血鬼的攻击力:" + m.getAttack());
		System.out.println("英雄的防御力:" + this.defence);
		System.out.println(this.name + "受到"+lostLife+"点伤害");

		System.out.println(this.name + "剩余血量:" + this.hp);

		return lostLife;
	}



	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getHp() {
		return hp;
	}
	public void setHp(int hp) {
		this.hp = hp;
	}
	public int getAttack() {
		return attack;
	}
	public void setAttack(int attack) {
		this.attack = attack;
	}
	public int getDefence() {
		return defence;
	}
	public void setDefence(int defence) {
		this.defence = defence;
	}
	public int getOwnMoney() {
		return ownMoney;
	}
	public void setOwnMoney(int ownMoney) {
		this.ownMoney = ownMoney;
	}
	public List<Weapon> getWeaponBag() {
		return weaponBag;
	}
	public void setWeaponBag(List<Weapon> weaponBag) {
		this.weaponBag = weaponBag;
	}
	public List<Armor> getArmorBag() {
		return armorBag;
	}
	public void setArmorBag(List<Armor> armorBag) {
		this.armorBag = armorBag;
	}
	public List<Shoes> getShoesBag() {
		return shoesBag;
	}
	public void setShoesBag(List<Shoes> shoesBag) {
		this.shoesBag = shoesBag;
	}
	public List<Shield> getShieldBag() {
		return shieldBag;
	}
	public void setShieldBag(List<Shield> shieldBag) {
		this.shieldBag = shieldBag;
	}
	public Equipment getEquipment() {
		return equipment;
	}
	public void setEquipment(Equipment equipment) {
		this.equipment = equipment;
	}


}

